<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\UserController;
use App\Http\Controllers\Api\MenuController;
use App\Http\Controllers\Api\RoleController;
use App\Http\Controllers\Api\AccountController;
use App\Http\Controllers\Api\AudioController;
use App\Http\Controllers\Api\FolderController;
use App\Http\Controllers\Api\FootageController;
use App\Http\Controllers\Api\IpController;
use App\Http\Controllers\Api\PapperController;
use App\Http\Controllers\Api\PartController;
use App\Http\Controllers\Api\PlatformController;
use App\Http\Controllers\Api\ProductController;
use App\Http\Controllers\Api\TagController;
use App\Http\Controllers\Api\TaskController;
use App\Http\Controllers\Api\VideoController;
use App\Http\Controllers\Common\TestController;
use App\Http\Controllers\Api\ConfigController;
use App\Http\Controllers\Api\PackController;
use App\Http\Controllers\Api\QuestionController;
use App\Http\Controllers\Api\QtagController;
use App\Http\Controllers\Api\KpiController;
use App\Http\Controllers\Api\ArticleController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::middleware('auth:sanctum')->group(function (){
    Route::prefix('config')->group(function () {
        Route::post('save',  [ConfigController::class, 'save']);
        Route::get('get',  [ConfigController::class, 'getInfo']);
    });

    Route::prefix('user')->group(function () {
        Route::get('info/{id?}',  [UserController::class, 'show']);
        Route::post('store',  [UserController::class, 'store']);
        Route::post('update/{id?}',  [UserController::class, 'update']);
        Route::get('/',  [UserController::class, 'index']);
        Route::get('menu',  [UserController::class, 'menus']);
    });
    
    Route::prefix('menu')->group(function () {
        Route::get('info/{id?}',  [MenuController::class, 'show']);
        Route::post('store',  [MenuController::class, 'store']);
        Route::post('update/{id?}',  [MenuController::class, 'update']);
        Route::delete('destroy/{id?}',  [MenuController::class, 'destroy']);
        Route::get('lists',  [MenuController::class, 'lists']);
    });
    
    Route::prefix('role')->group(function () {
        Route::get('info/{id?}',  [RoleController::class, 'show']);
        Route::post('store',  [RoleController::class, 'store']);
        Route::post('update/{id?}',  [RoleController::class, 'update']);
        Route::delete('destroy/{id?}',  [RoleController::class, 'destroy']);
        Route::get('lists',  [RoleController::class, 'lists']);
    });
    
    Route::prefix('account')->group(function () {
        Route::get('info/{id?}',  [AccountController::class, 'show']);
        Route::post('store',  [AccountController::class, 'store']);
        Route::post('update/{id?}',  [AccountController::class, 'update']);
        Route::post('destroy',  [AccountController::class, 'destroy']);
        Route::get('lists',  [AccountController::class, 'lists']);
        Route::post('auth',  [AccountController::class, 'authUser']);
    });
    
    Route::prefix('audio')->group(function () {
        Route::get('info/{id?}',  [AudioController::class, 'show']);
        Route::post('store',  [AudioController::class, 'store']);
        Route::post('update/{id?}',  [AudioController::class, 'update']);
        Route::post('destroy',  [AudioController::class, 'destroy']);
        Route::get('lists',  [AudioController::class, 'lists']);
        Route::post('check',  [AudioController::class, 'checkExists']);
    });
    
    Route::prefix('folder')->group(function () {
        Route::get('info/{id?}',  [FolderController::class, 'show']);
        Route::post('store',  [FolderController::class, 'store']);
        Route::post('update/{id?}',  [FolderController::class, 'update']);
        Route::post('destroy',  [FolderController::class, 'destroy']);
        Route::get('lists',  [FolderController::class, 'lists']);

        Route::prefix('label')->group(function () {
            Route::get('info/{id?}',  [FolderController::class, 'showLabel']);
            Route::post('store',  [FolderController::class, 'storeLabel']);
            Route::post('update/{id?}',  [FolderController::class, 'updateLabel']);
            Route::post('destroy',  [FolderController::class, 'destroyLabel']);
            Route::get('lists',  [FolderController::class, 'listsLabel']);
        });
    });
    
    Route::prefix('footage')->group(function () {
        Route::get('info/{id?}',  [FootageController::class, 'show']);
        Route::post('store',  [FootageController::class, 'store']);
        Route::post('update/{id?}',  [FootageController::class, 'update']);
        Route::post('destroy',  [FootageController::class, 'destroy']);
        Route::get('lists',  [FootageController::class, 'lists']);
        Route::post('generate',  [FootageController::class, 'generateVideo']);
    });
    
    Route::prefix('ip')->group(function () {
        Route::get('info/{id?}',  [IpController::class, 'show']);
        Route::post('store',  [IpController::class, 'store']);
        Route::post('update/{id?}',  [IpController::class, 'update']);
        Route::post('destroy',  [IpController::class, 'destroy']);
        Route::get('lists',  [IpController::class, 'lists']);
        Route::post('auth',  [IpController::class, 'authUser']);
    });
    
    Route::prefix('papper')->group(function () {
        Route::get('info/{id?}',  [PapperController::class, 'show']);
        Route::post('store',  [PapperController::class, 'store']);
        Route::post('update/{id?}',  [PapperController::class, 'update']);
        Route::post('destroy',  [PapperController::class, 'destroy']);
        Route::get('lists',  [PapperController::class, 'lists']);
        Route::post('addvideo',  [PapperController::class, 'addVideo']);
        Route::post('sortvideo',  [PapperController::class, 'sortVideo']);
    });
    
    Route::prefix('part')->group(function () {
        Route::get('info/{id?}',  [PartController::class, 'show']);
        Route::post('store',  [PartController::class, 'store']);
        Route::post('update/{id?}',  [PartController::class, 'update']);
        Route::post('destroy',  [PartController::class, 'destroy']);
        Route::get('lists',  [PartController::class, 'lists']);
    });
    
    Route::prefix('platform')->group(function () {
        Route::get('info/{id?}',  [PlatformController::class, 'show']);
        Route::post('store',  [PlatformController::class, 'store']);
        Route::post('update/{id?}',  [PlatformController::class, 'update']);
        Route::post('destroy',  [PlatformController::class, 'destroy']);
        Route::get('lists',  [PlatformController::class, 'lists']);
    });
    
    Route::prefix('product')->group(function () {
        Route::get('info/{id?}',  [ProductController::class, 'show']);
        Route::post('store',  [ProductController::class, 'store']);
        Route::post('update/{id?}',  [ProductController::class, 'update']);
        Route::post('destroy',  [ProductController::class, 'destroy']);
        Route::get('lists',  [ProductController::class, 'lists']);
        Route::post('check',  [ProductController::class, 'checkExists']);
    });
    
    Route::prefix('tag')->group(function () {
        Route::get('info/{id?}',  [TagController::class, 'show']);
        Route::post('store',  [TagController::class, 'store']);
        Route::post('update/{id?}',  [TagController::class, 'update']);
        Route::post('destroy',  [TagController::class, 'destroy']);
        Route::get('lists',  [TagController::class, 'lists']);
    });
    
    Route::prefix('task')->group(function () {
        Route::get('info/{id?}',  [TaskController::class, 'show']);
        Route::post('store',  [TaskController::class, 'store']);
        Route::post('update/{id?}',  [TaskController::class, 'update']);
        Route::post('destroy',  [TaskController::class, 'destroy']);
        Route::get('lists',  [TaskController::class, 'lists']);
        Route::get('summary',  [TaskController::class, 'summary']);
        Route::post('publish/save',  [TaskController::class, 'savePublish']);
        Route::post('updateall',  [TaskController::class, 'updateAll']);
    });
    
    Route::prefix('video')->group(function () {
        Route::get('info/{id?}',  [VideoController::class, 'show']);
        Route::post('store',  [VideoController::class, 'store']);
        Route::post('update/all',  [VideoController::class, 'updateAll']);
        Route::post('update/{id?}',  [VideoController::class, 'update']);
        Route::post('destroy',  [VideoController::class, 'destroy']);
        Route::get('lists',  [VideoController::class, 'lists']);
        Route::post('split/{id?}',  [VideoController::class, 'split']);
        Route::post('check',  [VideoController::class, 'check']);
    });

    Route::get('test/videogen', [TestController::class, 'videogen']);

    Route::prefix('pack')->group(function () {
        Route::get('info/{id?}',  [PackController::class, 'show']);
        Route::post('store',  [PackController::class, 'store']);
        Route::post('update/{id?}',  [PackController::class, 'update']);
        Route::post('destroy',  [PackController::class, 'destroy']);
        Route::get('lists',  [PackController::class, 'lists']);
        Route::post('addvideo',  [PackController::class, 'addVideo']);
        Route::post('removevideo',  [PackController::class, 'removeVideo']);
    });
    
    Route::prefix('question')->group(function () {
        Route::get('info/{id?}',  [QuestionController::class, 'show']);
        Route::post('store',  [QuestionController::class, 'store']);
        Route::post('update/{id?}',  [QuestionController::class, 'update']);
        Route::post('destroy',  [QuestionController::class, 'destroy']);
        Route::get('lists',  [QuestionController::class, 'lists']);
    });
    
    Route::prefix('qtag')->group(function () {
        Route::get('info/{id?}',  [QtagController::class, 'show']);
        Route::post('store',  [QtagController::class, 'store']);
        Route::post('update/{id?}',  [QtagController::class, 'update']);
        Route::post('destroy',  [QtagController::class, 'destroy']);
        Route::get('lists',  [QtagController::class, 'lists']);
    });
    
    Route::prefix('kpi')->group(function () {
        Route::get('info/{id?}',  [KpiController::class, 'show']);
        Route::post('store',  [KpiController::class, 'store']);
        Route::post('update/{id?}',  [KpiController::class, 'update']);
        Route::post('destroy',  [KpiController::class, 'destroy']);
        Route::get('lists',  [KpiController::class, 'lists']);
        Route::get('summary',  [KpiController::class, 'summary']);
    });
    
    Route::prefix('article')->group(function () {
        Route::get('info/{id?}',  [ArticleController::class, 'show']);
        Route::post('store',  [ArticleController::class, 'store']);
        Route::post('update/{id?}',  [ArticleController::class, 'update']);
        Route::post('destroy',  [ArticleController::class, 'destroy']);
        Route::get('lists',  [ArticleController::class, 'lists']);
    });
});

// Route::post('login', [UserController::class, 'login']);
